<script>
	import storageKeyEnum from '@/common/enum/storage-key.enum.js'
	export default {
		globalData: {
			socketId: '',
			service_uuid: "0000FFFF-0000-1000-8000-00805F9B34FB",
			characteristic_write_uuid: "0000FF01-0000-1000-8000-00805F9B34FB",
			characteristic_read_uuid: "0000FF02-0000-1000-8000-00805F9B34FB",
			mtu: 19,
			constMtu: 128,
			md5Key: "",
			platform: '',
			sequenceControl: -1,
			sequenceNumber: -1
		},
		onLaunch: function() {
			this.upgradeVersion();
			// console.log('App Launch');
		},
		onShow: function() {
			// console.log('App Show');
		},
		onHide: function() {
			// console.log('App Hide');
		},
		methods: {
			upgradeVersion() {
				const updateManager = uni.getUpdateManager();

				updateManager.onCheckForUpdate(function(res) {
					// 请求完新版本信息的回调
					console.log(res.hasUpdate);
				});

				var that = this;
				// console.log('that',that)
				let userInfo = this.$store.getters.GET_VALUE("GET_USER_INFO");
				updateManager.onUpdateReady(function(res) {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启小程序？',
						success(res) {
							if (res.confirm) {
								uni.removeStorageSync(storageKeyEnum.home_icon_list + userInfo.id ? userInfo.id:'');
								uni.removeStorageSync(storageKeyEnum.twisted_egg_bindingGoodsList);
								// that.$store.commit("SET_TOKEN", '')
								// that.$store.commit("SET_USER_INFO", '');
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate();
							}
						}
					});
				});

				updateManager.onUpdateFailed(function(res) {
					// 新的版本下载失败
				});
			},

			// 消息提示-模态框
			err(message) {
				var _that = this;
				uni.showModal({
					title: '',
					content: message,
					success(res) {}
				});
			},

			// 格式化图片后缀
			formatImageSuffix(fileName) {
				const suffix = '.jpg';
				if (fileName.endsWith(suffix)) {
					return fileName;
				} else {
					return fileName.concat(suffix);
				}
			}
		}
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	@import 'uview-ui/index.scss';

	page {
		background-color: #f2f3f5;
	}

	// 超出长度用...省略。如u-lint-ellipsis-2，满第2行就...省略
	@for $i from 1 through 10 {
		.u-lint-ellipsis-#{$i} {
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: $i;
			-webkit-box-orient: vertical;
		}
	}

	.u-flex {
		display: flex;
	}

	.u-flex-center {
		display: flex;
		align-items: center;
	}

	.u-flex-content-center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.u-flex-row {
		display: flex;
		flex-direction: row;
	}

	.u-flex-column {
		display: flex;
		flex-direction: column;
	}

	.m-flex-column {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;
	}

	.m-flex-row {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		width: 100%;
	}

	.u-row-between {
		justify-content: space-between !important;
		align-items: center;
	}

	.u-row-around {
		justify-content: space-around !important;
		align-items: center;
	}

	.u-row-start {
		justify-content: start !important;
		align-items: center;
	}

	.u-row-end {
		justify-content: end !important;
		align-items: center;
	}

	.u-row-flex-start {
		justify-content: flex-start !important;
		align-items: center;
	}

	.u-row-flex-end {
		justify-content: flex-end !important;
		align-items: center;
	}

	.u-row-center {
		justify-content: center !important;
		align-items: center !important;
	}

	// 示例：u-font-10标识字号10rpx，范围：1-100
	@for $i from 1 through 100 {
		.u-font-#{$i} {
			font-size: $i + rpx;
		}
	}

	// 示例：u-m-10标识外边距都是10rpx，范围：1-100
	@for $i from 1 through 100 {
		.u-m-#{$i} {
			margin: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-p-#{$i} {
			padding: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-m-t-#{$i} {
			margin-top: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-p-t-#{$i} {
			padding-top: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-m-r-#{$i} {
			margin-right: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-p-r-#{$i} {
			padding-right: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-m-b-#{$i} {
			margin-bottom: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-p-b-#{$i} {
			padding-bottom: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-m-l-#{$i} {
			margin-left: $i + rpx;
		}
	}

	@for $i from 1 through 100 {
		.u-p-l-#{$i} {
			padding-left: $i + rpx;
		}
	}

	//上传图片全局样式调整-begin
	/deep/ .u-upload__deletable {
		// 控制大小、圆弧、背景颜色
		height: 40rpx !important;
		width: 40rpx !important;
		border-radius: 50% !important;
		background-color: red !important;
	}

	/deep/ .u-upload__deletable__icon {
		// 控制 X 的大小
		transform: scale(0.9) !important;
		position: relative !important;
	}

	/deep/ .u-upload__wrap__preview {
		margin: 0 8px 0px 0 !important;
	}

	//上传图片全局样式调整-end

	/deep/ .u-textarea {
		padding: 18rpx 0 !important;
	}

	// 顶部弹窗提示-begin
	.tool-tip-text {
		// 长度自动
		color: #fff;
		text-align: center;
		padding: 15rpx;
		border-radius: 16rpx;
		font-size: 26rpx;
		background-color: #000;
		box-shadow: 0px 0px 2px #968e62;
		position: absolute;
		z-index: 1;
		font-size: $f-base;

		.tip-text {}
	}

	.tool-tip-text::after {
		content: " ";
		position: absolute;
		transform: rotate(270deg);
		bottom: -36%;
		left: 40%;
		border-width: 12rpx;
		border-style: solid;
		border-color: transparent #000 transparent transparent;
	}

	// 顶部弹窗提示-end
</style>
